#include "widget.h"
#include "ui_widget.h"


Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    setWindowTitle("服务器");

    Server* tcpserver = new Server();
    connect(tcpserver,&Server::logInfoMessage,this,&Widget::handleTolog);
    tcpserver->init();

}

Widget::~Widget()
{
    delete ui;
}

//处理日志信息 更新到ui界面上
void Widget::handleTolog(Log::MessageType type, const QString &message)
{
    switch (type)
    {
        case Log::MessageType::Info:
            ui->listWidget->addItem(message);
            break;

        case Log::MessageType::Warning:
            ui->listWidget->addItem(message);
            break;

        case Log::MessageType::Error:
            ui->listWidget->addItem(message);
            break;

    }
}



